package com.wen.controller;

import com.wen.pojo.InStore;
import com.wen.pojo.Store;
import com.wen.service.InStoreService;
import com.wen.service.ProductService;
import com.wen.utils.PageBean;
import com.wen.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/instore")
public class InStoreController {
    @Autowired
    private InStoreService inStoreService;

    //所有仓库信息
    @Autowired
    private ProductService productService;

    @RequestMapping("/store-list")
    public Result allStoreList() {
        List<Store> storeList = productService.findStoreList();
        return Result.ok(200, "查询成功", storeList);
    }

    //分页查询入口单
    @RequestMapping("/instore-page-list")
    public Result<PageBean<InStore>> pageList(Integer pageNum, Integer pageSize, InStore inStore) {
        PageBean<InStore> inStorePageBean = inStoreService.allListStore(pageNum, pageSize, inStore);
        return Result.ok(200, "查询成功", inStorePageBean);
    }

    //确认入库单（改状态，涨库存）
    @RequestMapping("/instore-confirm")
    public Result confirmInstore(@RequestBody InStore inStore){
        return inStoreService.confirmInstore(inStore);
    }
}
